using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Manager_SQL_Query : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["IsAdmin"] != "S")
        {
            Response.Redirect("../Default.aspx");
            return;
        }
    }
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        clsWebShop cls = new clsWebShop();
        string SQL = txtQuery.Text.ToLower();

        if (SQL != "")
        {
            if (txtQuery.Text.StartsWith("insert") || txtQuery.Text.StartsWith("update") || txtQuery.Text.StartsWith("delete"))
            {
                cls.UpdateData(SQL);
                // int iFrom = SQL.IndexOf("from") + 4;
                //  SQL = SQL.Substring(iFrom);
            }
            else
            {

                grv_Master.DataSource = cls.GetData(SQL);
                grv_Master.DataBind();
            }

        }
    }
}
